#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int temp;
	int flag;
	cin >> flag;
	n--;
	int minsum, maxsum;
	minsum = maxsum = flag;
	while(n--)
	{
		cin >> temp;
		if (temp != flag)
		{
			flag = temp;
			minsum += flag;
		}
		maxsum += temp;
	}
	cout << maxsum << endl;
	cout << minsum << endl;
	return 0;
}
